﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Geometry
{
    public class Point : IPoint
    {
        public Point()
        {

        }

        public Point(double x)
        {
            X = x;
        }
        public double X { get; set; }

        public double Distance
        {
            get
            {
                return X;
            }
        }

        public void Move(double dx)
        {
            X += dx;
        }

        public virtual void Reset()
        {
            X = 0;
        }
        public double DistanceFrom(double x)
        {
            return Math.Abs(X-x);
        }
        public double DistanceFrom(Point p)
        {
            return DistanceFrom(p.X);
        }
        public override string ToString()
        {
            return X.ToString();
        }

        public override bool Equals(object obj)
        {
            if (obj == null) return false;

            var p = (Point)obj; // null or Point

            if (p == null) return false;

            if (p.X == X) return true;

            return false;
        }
    }
}
